package com.dyh.quickdemozwei.hxfz;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.SimpleFormatter;

public class Test11 {

    @Test
    public void test(){
        List<Long> lst = Lists.newArrayList(
                257L,
                273L,
                101037L,
                157037L,
                157038L,
                203000L,
                1730081L,
                1730137L,
                2051031L,
                201100005L,
                201100021L,
                201100080L,
                201100121L,
                2021751510L,
                2021751800L
        );
        String s = "INSERT INTO oms.sys_user_resource\n" +
                "            ( merchant_id, user_id, resource_id, create_user_id, update_user_id, create_time, last_update_time, auth_status)\n" +
                "    VALUES( 1, 1234570626, %s, 123460038, 123460038, '2023-07-17 10:09:59', '2023-07-17 10:09:59', 0);";


        lst.forEach(e-> System.out.println(String.format(s,e)));
    }


    @Test public void testJa(){
        String str = "[\"dawdawd\",\"dawdawdjli\",\"dawkdhiauwd\"]";

        JSONArray ja = JSON.parseArray(str);

        System.out.println();
    }

//    @Test public void testComput(){
//        Map<String, Integer> map = new HashMap<>();
//
//        map.compute("x",(k,v)->)
//    }


    @Setter@Getter
    static class Resp{
        Object data;
    }
    @Setter@Getter
    static class XX{
        String name;
        Long code;
        List<String> lst;
        List<Long> lst1;
    }


    @Test public void testx(){
        Resp resp = new Resp();
        XX xx = new XX();
        xx.setName("dawdawd");

        resp.setData(xx);

        String str = JSON.toJSONString(resp);

        Resp out = JSON.parseObject(str,Resp.class);

        System.out.println();

    }

    @Test public void testy(){
        JSONObject jo = new JSONObject();
        jo.put("name","xawd");
        jo.put("code","123123123");
        jo.put("lst","123123123");
        jo.put("lst1","11x,22,33");

        XX xx = jo.toJavaObject(XX.class);

        System.out.println();
    }

    @Test public void testy2(){
        Date d = new Date();

        SimpleDateFormat sdf = new SimpleDateFormat(
//                "yyyy-MM-dd HH:mm:ss"
                "yyyy-MM-dd 00:00:00"
        );
        System.out.println(sdf.format(d));
    }

    @Test public void testy3() {
        // 获取当前日期
        Date today = new Date();

        // 获取上个月1号
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(today);
        calendar.add(Calendar.MONTH, -1); // 减去一个月
        calendar.set(Calendar.DAY_OF_MONTH, 1); // 设置日期为1号
        Date firstDayOfLastMonth = calendar.getTime();

        // 格式化输出结果
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String formattedDate = formatter.format(firstDayOfLastMonth);

        // 输出结果
        System.out.println("First day of last month: " + formattedDate);
    }


    @Test public void testY4(){

        String x = "ABCA13                          BAOZUN          00000000000832023-12-13 03:30:25";
        StringBuilder sb = new StringBuilder(x);
        sb.append(StringUtils.leftPad("TMALL",10," "));


        StringBuffer content = new StringBuffer();
        content.append(StringUtils.rightPad("ABCA10", 32, " "));
        content.append(StringUtils.rightPad("LEQEE", 16, " "));
        content.append(StringUtils.leftPad("422", 13, "0"));
        content.append(StringUtils.rightPad("2023-12-13 03:30:25", 28, " "));

        System.out.println(content.length());

        content.append(StringUtils.rightPad("TMALL", 20, " "));

        System.out.println(content.toString());
//        String xx = null;
//        System.out.println(
//                !StringUtils.isEmpty( xx) &&  Lists.newArrayList("SUCCESS").contains(xx)
//
//        );
    }


    public static void main(String[] args) {


    }
}
